/**
 * Created by Administrator on 2016/2/18 0018.
 */
define(function(require, exports, module) {

    var $ = require('jquery');
    require('bootstrap');
    var List = require('../../util/list.js');
    var template = require('template');
    //加载轮播图
    exports.loadCarousel = function (param) {
        var list = new List();
        list.options = {
            template: "carousel-template",
            container: "carousel-data",
            url: $CONFIG.base_url + "/api/post/advertise/list",
            param: param
        };
        list.load();

    };

    exports.loadCarousel({'type':"轮播banner", 'status': '0'});

    exports.loadSysNews = function (param) {
        var getting = $.get($CONFIG.base_url + "/api/post/list", param);
        getting.done(function (data) {
            if (data.result[0].postContent.length > 52) {
                data.result[0].postContent = data.result[0].postContent.substring(0, 52) + '...'
            }
            var year=data.result[0].postDate.substr(0,4);
            var month=data.result[0].postDate.substr(5,2);
            var day=data.result[0].postDate.substr(8,2);
            $('.news-body .time').html('<div class="day">'+day+'</div><span class="year">'+year+'</span><span class="month">.'+month+'</span>' )

            var html = template("list-template", data);
            $("#news-data").empty().append(html);
            $(".timeago").timeago();
        })
    };
    exports.loadSysNews({'type':'0'});

    exports.loadAboutNews = function (param) {
        var getting = $.get($CONFIG.base_url + "/api/post/list", param);
        getting.done(function (data) {
            if (data.result[0].postContent.length > 52) {
                data.result[0].postContent = data.result[0].postContent.substring(0, 52) + '...'
            }
            var html = template("list-template1", data);
            $("#news-data1").empty().append(html);
            $(".timeago").timeago();
        })
    };
    exports.loadAboutNews({'type':'1'});

    $("#login-submit").click(function(){
        window.location.href = $CONFIG.base_url + "/login";
    })


});